home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / __MANDEL / MANDELBR / CMANDELP.C1 < prev    next >
Text File  |  1992-03-25  |  1KB  |  66 lines

  1. //    CMandelPictFile.c
  2.  
  3. #include "CMandelDoc.h"
  4. #include "CMandelMap.h"
  5. #include "CMandelPictFile.h"
  6.  
  7. #define        PICT_HEADER_SIZE    512
  8.  
  9. static OSErr                sPutError;
  10. static long                    sPutCount;
  11. static CMandelPictFile *    sFile;
  12.  
  13. extern PicHandle            gPixPictH;
  14. extern OSErr                gLastError;
  15.  
  16. void    CMandelPictFile::IMandelPictFile(CMandelDoc *theMandelDoc)
  17. {
  18.     CDataFile::IDataFile();
  19.     
  20.     itsMandelDoc = theMandelDoc;
  21. }
  22.  
  23.     static pascal void MyPutPicProc(Ptr theDataP, unsigned theCount);
  24.     static pascal void MyPutPicProc(Ptr theDataP, unsigned theCount)
  25.     {
  26.         sPutCount += theCount;
  27.         if (gPixPictH)
  28.             (**gPixPictH).picSize = sPutCount;
  29.         
  30.         if (sPutError) return;
  31.         
  32.         TRY {
  33.             sFile->WriteSome(theDataP, theCount);
  34.         }
  35.         CATCH {
  36.             sPutError = gLastError;
  37.             NO_PROPAGATE;
  38.         }
  39.         ENDTRY;
  40.     }
  41.     
  42. void    CMandelPictFile::WriteAll(Handle theDataH)
  43. {
  44.     CMandelMap *aMandelMap = itsMandelDoc->GetMandelMap();
  45.     Handle        aH;
  46.     PicHandle    aPictH;
  47.     
  48.     aH = NewHandleClear(PICT_HEADER_SIZE + sizeof(Picture));
  49.     FailNIL(aH);
  50.     WriteSome(*aH, PICT_HEADER_SIZE + sizeof(Picture));
  51.     DisposHandle(aH);
  52.     
  53.     sPutError = noErr;
  54.     sPutCount = sizeof(Picture);
  55.     sFile = this;
  56.     
  57.     aMandelMap->SetPutPicProc((ProcPtr)MyPutPicProc);
  58.     aPictH = aMandelMap->GetPicHandle();
  59.     aMandelMap->ResetStdProcs();
  60.     
  61.     SetMark((long)PICT_HEADER_SIZE, fsFromStart);
  62.     WriteSome((Ptr)*aPictH, sizeof(Picture));
  63.     
  64.     KillPicture(aPictH);
  65. }
  66.